<!-- 企业信息弹框 -->
<template>
  <el-dialog :visible.sync="visible" @close="handleClose" title="企业详细信息" width="720px">
    <div class="recruiter-detail">
      <div class="header">
        <img :src="company.avatar || defaultAvatar" class="logo">
        <div>
          <h3>{{ company.name }}</h3>
          <span class="industry-badge">{{ company.companyIndustry }}</span>
        </div>
      </div>
        
      <!-- 企业信息表格 -->
      <div class="company-info-table">
        <div class="table-row">
          <div class="table-cell label-cell">企业ID</div>
          <div class="table-cell value-cell">{{ company.companyId }}</div>
          <div class="table-cell label-cell">企业地址</div>
          <div class="table-cell value-cell">{{ company.location }}</div>
        </div>
          
        <div class="table-row">
          <div class="table-cell label-cell">创建日期</div>
          <div class="table-cell value-cell">{{ formatDate(company.createDate) }}</div>
          <div class="table-cell label-cell">休息制度</div>
          <div class="table-cell value-cell">{{ getWorkTimeTypeText(company.workTimeType) }}</div>
        </div>
          
        <div class="table-row">
          <div class="table-cell label-cell">工作时间</div>
          <div class="table-cell value-cell">{{ formatWorkTime(company) }}</div>
          <div class="table-cell label-cell">企业规模</div>
          <div class="table-cell value-cell">{{ company.scale || '未说明' }}</div>
        </div>
      </div>
        
      <!-- 企业简介 -->
      <div class="company-introduction">
        <h4>企业简介</h4>
        <p>{{ company.companyIntroduction || '暂无简介' }}</p>
      </div>
    </div>
    
    <!-- <template #footer>
      <span class="dialog-footer">
        <el-button @click="visible = false">关闭</el-button>
      </span>
    </template> -->
  </el-dialog>
</template>

<script>
export default {
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    company: {
      type: Object,
      default: () => ({})
    }
  },
  created() {
    console.log('传递的企业',this.company);
  },
  data() {
    return {
      defaultAvatar: 'https://picsum.photos/200/200?random=0'
    };
  },
  methods: {
    // 格式化日期
    formatDate(dateString) {
      if (!dateString) return '';
      const date = new Date(dateString);
      return date.toLocaleDateString('zh-CN', {
        year: 'numeric',
        month: 'long',
        day: 'numeric'
      });
    },
    
    // 格式化工作时间
    formatWorkTime(company) {
      if (!company.workDayStartTime || !company.workDayEndTime) return '未设置';
      
      const startTime = new Date(company.workDayStartTime);
      const endTime = new Date(company.workDayEndTime);
      
      const startHour = startTime.getHours().toString().padStart(2, '0');
      const startMinute = startTime.getMinutes().toString().padStart(2, '0');
      const endHour = endTime.getHours().toString().padStart(2, '0');
      const endMinute = endTime.getMinutes().toString().padStart(2, '0');
      
      return `${startHour}:${startMinute} - ${endHour}:${endMinute}`;
    },
    
    // 获取工作时间类型文本
    getWorkTimeTypeText(type) {
      const typeMap = {
        'SINGLE_REST': '单休',
        'DOUBLE_REST': '双休',
        'FLEXIBLE': '弹性工作制',
      };
      return typeMap[type] || type;
    },

    handleClose() {
      this.$emit('update:visible', false); // 通知父组件更新visible
    }
  }
};
</script>

<style scoped>
.recruiter-detail {
  padding: 24px;
}

.header {
  display: flex;
  align-items: center;
  margin-bottom: 24px;
}

.logo {
  width: 96px;
  height: 96px;
  border-radius: 8px;
  margin-right: 24px;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

h3 {
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 8px 0;
  color: #303133;
}

.industry-badge {
  background-color: #f5f7fa;
  color: #606266;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 13px;
}

/* 企业信息表格 */
.company-info-table {
  margin-bottom: 24px;
  border: 1px solid #ebeef5;
  border-radius: 6px;
  overflow: hidden;
}

.table-row {
  display: flex;
  border-bottom: 1px solid #ebeef5;
}

.table-row:last-child {
  border-bottom: none;
}

.table-cell {
  padding: 14px 16px;
  font-size: 14px;
}

.label-cell {
  width: 120px;
  background-color: #fafafa;
  color: #606266;
  font-weight: 500;
}

.value-cell {
  flex: 1;
  color: #303133;
}

/* 企业简介 */
.company-introduction {
  margin-top: 24px;
}

h4 {
  font-size: 16px;
  font-weight: 500;
  color: #303133;
  margin: 0 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid #ebeef5;
}

p {
  font-size: 14px;
  color: #606266;
  line-height: 1.8;
  margin: 0;
}
</style>